import 'package:flutter/material.dart';
import 'package:flutter_soundmagus/widget/zflistview.dart';

///eq频点视图
class EqPdView extends StatelessWidget {
  ///选中的频点
  final int pd;
  final int pdCount;

  ///点击频点
  final void Function(int pd)? onPress;
  const EqPdView({Key? key, this.pd = 0, this.onPress, required this.pdCount})
      : super(key: key);

  //频点
  Widget _buildPd(BuildContext context, int i) {
    final color = pd == i ? Theme.of(context).colorScheme.secondary : Colors.white;
    return Container(
      width: 12,
      height: 12,
      decoration: BoxDecoration(border: Border.all(color: color, width: 2)),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.fromLTRB(20, 50, 0, 0),
      child: ZFListView(
        itemCount: pdCount,
        itemBuilder: (c, i) {
          return GestureDetector(
            child: _buildPd(context, i),
            onTap: () => onPress?.call(i),
          );
        },
      ),
    );
  }
}
